<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="游戏搜索引擎，Flash小游戏搜索, 网页游戏搜索, 手机游戏搜索。在这里寻找上万款游戏！" />
<meta name="keywords" content="游戏, 搜索, flash 游戏, 网页游戏, 手机游戏, 搜索引擎" />
<?php 

if (!isset($_SESSION)) {
 	session_start();
	//session_regenerate_id();
}

$user = $_SESSION['userdata'];


$user_cookie = $_COOKIE['youxisoso_user'];
$user_cookie = explode(":", $user_cookie);

if (!$user_cookie || count($user_cookie) < 2){ //如果用户cookie不存在，则设置一个cookie；
	$custom_id = $user ? $user->ID :  uniqid();
	$user_cookie = array($custom_id ,  $user ? '1' : '0');
	setcookie('youxisoso_user', join($user_cookie, ":"), time()+3600*24*30);
}else{
	//如果用户cookie已经存在，且用户已登录的话，则判断cookie中记录的ID是否与登录用户一致，如果不一致将其ID设置为已登录的用户ID
	if($user && $user_cookie['ID'] != $user->ID){
		$user_cookie = array($user->ID , '1');
		
		setcookie('youxisoso_user', join($user_cookie, ":"), time()+3600*24*30);
	}
}


	$blog_title = get_bloginfo('name');
   $siteurl = get_bloginfo('template_url');
?>
<title><?php echo $blog_title?></title>
<link href="<?php echo $siteurl ?>/js/lib/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="all" href="<?php echo $siteurl ?>/shouye.css" />
	<script src="<?php echo $siteurl ?>/js/lib/jquery.js" type="text/javascript"></script>
<script src="<?php echo $siteurl ?>/js/lib/jquery.autocomplete.js" type="text/javascript"></script>
<script src="<?php echo $siteurl ?>/js/lib/function.js" type="text/javascript"></script>
<script src="<?php echo $siteurl ?>/js/jquery.cookie.js" type="text/javascript"></script>
<script src="<?php echo $siteurl ?>/js/wbox/wbox-min.js" type="text/javascript"></script>
<link href="<?php echo $siteurl ?>/js/wbox/wbox/wbox-min.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $siteurl ?>/js/delay_print_img.js" type="text/javascript"></script>
 <script type="text/javascript" > 
	//<![CDATA[
 	function goSearch(event){
		if(event.keyCode==13) {
	    	 $("#searchform").submit();
	     }
		}

	$(document).ready(function (){
			//document.getElementById("all").focus();
			var wanguo = "<span>最近玩过：</span><li><a href='#'>美女化妆</a></li>";
			var user_cookie_id_temp =  $.cookie("youxisoso_user");
			var user_cookie_id = user_cookie_id_temp.substring(0,user_cookie_id_temp.indexOf(":"));
			$.ajax({
		        type:"GET",
		        url:"?page_id=190048",
		        data:{id:user_cookie_id},
		        beforeSend:function(){
		           
		         },             
		        success:function(data){ 
		          	   $("#zuijin").html(data);
		          	    	   
		        }            
		     });
		});
	
	//]]>
	   	 
</script>	
<script language="javascript" type="text/javascript">
$(function(){	
	$("#all").focus(function(){
			if($(this).val() == "输入游戏名称 游戏类型 关键词" ){
				$(this).val("");
			}else{
				$(this).css("color","#000");
			}
		}).blur(function(){
				if($(this).val() == "" ){
					$(this).val("输入游戏名称 游戏类型 关键词");
					$(this).css("color","#666");
				}else{
					$(this).css("color","#000");
				}
			});
});

function opWin(loc){
		var p = $("#"+loc).offset();

		var win = $("#loginWindow");
		if(win.length == 0){
   		$("body").append("<div id='loginWindow' style='position: absolute;left:43%;top:240px;width:280px;height:100px;"+
   		   		" background: #FFFFFF; display: none;'>ssss</div>");
   		$.ajax({
		   	url: "<?php bloginfo('template_url');?>/loginWin.html",
		   	success: function(data){
			   		$("#loginWindow").html(data);
			   		$("#loginWindow").fadeIn("slow");
			   		WB2.anyWhere(function(W){
				   		W.widget.connectButton({
				   				id: "wb_connect_btn",
				   				callback : {
				   					login:function(o){
				   						$.ajax({
				   				   			url: "<?php bloginfo('template_url');?>/register_ajax.php",
				   				   			data: {'action': 'login','login_type':'sina', 'out_id': o.id, 'out_name': o.screen_name},
				   				   			success: function (data){
			   				   						closeWin();
			   				   						if(loginCallBack){
			   					   						loginCallBack(data);
			   				   						}
				   				   				}	
				   				   			});
				   					}
				   				}
				   			});
				   		});
			   	}
		   	});
		}else{
   			win.css({"left":"43%", "top":"240px"});
			win.fadeIn("slow");
		}

   
	}

	function closeWin(){
   		$("#loginWindow").fadeOut("fast");
   		   
	}

function keyLogin(event){
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		
		if (keyCode == 13) {
		    login();
		}
	}

	function login(){
		var username = $('#username_input').val();
		var password = $('#password_input').val();

		$("#login_bt").attr('disabled', 'disabled');
		$("#loginstatus").html('');
		
		$.ajax({
			url: "<?php bloginfo('template_url');?>/register_ajax.php",
			data: {'action': 'login', 'username': username, 'password': password},
			success: function (data){
					if(data == '0'){
						$("#loginstatus").html('登录失败：用户名或密码不正确。');
						$("#loginstatus").css({'color': 'red'});
					}else if(data == '2'){
						$("#loginstatus").html('登录失败：用户名不存在。');
						$("#loginstatus").css({'color': 'red'});
					}else{
						closeWin();
						location.reload(true);
						if(loginCallBack){
   						loginCallBack(data);
						}
					}

					$("#login_bt").removeAttr('disabled');
				}	
			});
	}

	WB2.anyWhere(function(W){
		W.widget.connectButton({
				id: "wb_connect_btn",
				callback : {
					login:function(o){
	   						$('#login_type_id').val(o.id);
   						$('#login_type_name').val(o.screen_name);
   						$('#login_type_input').val('sina');
   						$("#login_form").submit();
					}
				}
			});
		});
	function indexinglogn(){
		    
		   opWin("indexdenglu");
	   }
</script>	
 </head>
<body>
	<div id="content">
		<p id="login">
		<?php if($user){?>
			欢迎你： <?php echo $user->display_name ? $user->display_name : $user->user_login;
			echo "&nbsp;&nbsp;经验值：";
			echo getUserEmpiricalValue($user->ID);
			if($user->user_status == 1){?>
			&nbsp;&nbsp;你还没有激活你的邮箱
		<?php }
		?>
		<script language="javascript" type="text/javascript">
		$(function(){	
			$("#indexdenglu").css("display","none");
		});	
		</script>
		&nbsp;&nbsp;&nbsp;&nbsp;<a href="/user_profile">个人中心</a>
		&nbsp;&nbsp;&nbsp;&nbsp;<a href="/logout">退出</a>
		
		<?php
		}else{?>
			<a href="/login" rel="nofollow">登录</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/register" rel="nofollow">注册</a>
		<?php }?>
		</p>
		<?php include_once 'index_content.html';?>
		
<?php get_footer();?>